
package com.sgame.android.data;

import java.io.Serializable;
import org.json.JSONException;
import org.json.JSONObject;

// Referenced classes of package com.mobage.us.android.data:
//            b

public class SystemMessage extends Message
    implements Serializable
{

    public SystemMessage()
    {
        timesToDisplay = 1;
    }

    public static SystemMessage fromJSON(JSONObject object)
    {
        SystemMessage systemmessage;
        (systemmessage = new SystemMessage()).title = object.optString("title", "");
        systemmessage.text = object.optString("text", "");
        systemmessage.linkUrl = object.optString("url");
        systemmessage.useAlert = object.optBoolean("alert", false);
        systemmessage.useWebView = object.optBoolean("web_view", false);
        systemmessage.timesToDisplay = object.optInt("times_to_display", 1);
        return systemmessage;
    }

    public JSONObject toJSON()
    {
    	JSONObject obj = new JSONObject();
        try
        {
            obj.put("title", title);
            obj.put("text", text);
            obj.put("url", linkUrl);
            obj.put("alert", useAlert);
            obj.put("web_view", useWebView);
            obj.put("times_to_display", timesToDisplay);
        }
        // Misplaced declaration of an exception variable
        catch(JSONException ex)
        {
            throw new RuntimeException("JSON error while converting system message to json", ((Throwable) (ex)));
        }
        return obj;
    }

    public int getTimesToDisplay()
    {
        return timesToDisplay;
    }

    public String getLinkUrl()
    {
        return linkUrl;
    }

    public boolean useWebVeiw()
    {
        return useWebView;
    }

    private static final long serialVersionUID = 1L;
    String linkUrl;
    boolean useWebView;
    int timesToDisplay;
}
